package cn.zxf.note.user.platform;

import cn.zxf.note.common.exception.BizException;
import lombok.AllArgsConstructor;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * Created by zengxf on 2020/3/25.
 */
@AllArgsConstructor
public enum PlatformEnum {

    WEAPP("weapp", "微信小程序"),
    ;

    public final String code;
    public final String name;

    public static PlatformEnum find(String code) {
        return Stream.of(PlatformEnum.values())
                .filter(e -> Objects.equals(e.code, code))
                .findFirst()
                .orElseThrow(() -> BizException.of("平台 code 不对！当前是：[%s]", code));
    }

}
